Resize by width
Asynchronously resizes an image to a specified width.
This feature resizes also the height of the image proportionally, without distorting it.
Syntax
resizeByWidth(image, widthPx)
Parameters
- 
image :
HTMLImageElement
The image element to resize. - 
widthPx :
number
The new width, in pixels, to resize the image to. 
Return
- Promise : 
Promise<HTMLImageElement>
A promise that resolves with the resized image element. 
Throws
Error
Thrown if the specified width is negative or if there are errors during the resizing process.
Examples
const editpix = new EditPix();
// image url
const url = "images/img.jpg";
// create image
var image = new Image();
image.src = url;
//waiting image load
image.onload = () => {
    // resize image by width
    editpix.resizeByWidth(image, 100)
        .then(resizedImage => {
            // render modified image
            document.body.appendChild(resizedImage)
        })
        .catch(error => { console.log(error) })
};